package com.example.mobile2021606177cke0615;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private TextView tvMainConnState;
    private TextView tvMainReadOrWrite;
    private TextView tvMainVersion;
    private TextView tvMainPath;
    private Button btnMainOpenDB;
    private Button btnMainCloseDB;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        MySQLiteOpenHelper openHelper = new MySQLiteOpenHelper(this, "SmartTraffic.db", null, 1);
        ContentValues values = new ContentValues();
        values.put("carnumber", "1");
        values.put("pcode", "2");
        values.put("pdatetime", "3");
        values.put("paddr", "4");
        SQLiteDatabase database = openHelper.getWritableDatabase();
        long result = database.insert("CarPeccancy", null, values);
        database.close();
        ContentValues values2 = new ContentValues();
        values2.put("Co2", 1);
        values2.put("Pm25", 2);
        values2.put("LightIntensity", 3);
        values2.put("humidity", 4);
        values2.put("temperature", 4);
        database = openHelper.getWritableDatabase();
        long result2 = database.insert("Sense", null, values2);
        database.close();
        ContentValues values3 = new ContentValues();
        values3.put("carnumber", "1");
        values3.put("number", "2");
        values3.put("pcardid", "3");
        values3.put("buydata", "4");
        values3.put("carbrand", "4");
        database = openHelper.getWritableDatabase();
        long result3 = database.insert("CarInfor", null, values3);
        database.close();


    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tvMainTitle);
        tvMainConnState = (TextView) findViewById(R.id.tvMainConnState);
        tvMainReadOrWrite = (TextView) findViewById(R.id.tvMainReadOrWrite);
        tvMainVersion = (TextView) findViewById(R.id.tvMainVersion);
        tvMainPath = (TextView) findViewById(R.id.tvMainPath);
        btnMainOpenDB = (Button) findViewById(R.id.btnMainOpenDB);
        btnMainCloseDB = (Button) findViewById(R.id.btnMainCloseDB);
    }
}